package com.jctrip.hotel.route.controller;

import com.jctrip.hotel.domain.dao.HtIdGeneratorDao;
import com.jctrip.hotel.domain.entity.HtIdGenerator;
import com.jctrip.hotel.route.model.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 主键id生成接口
 */
@Slf4j
@RestController
@RequestMapping("")
public class IdGeneratorController {

    @Autowired
    private HtIdGeneratorDao htIdGeneratorDao;

    @GetMapping("/id/generator")
    public Result<?> idGenerator() {
        HtIdGenerator htIdGenerator = new HtIdGenerator();
        htIdGeneratorDao.insert(htIdGenerator);
        return Result.ok("主键id是这个：" + htIdGenerator.getId());
    }
}
